package com.flx.dis.read.write.split.service.impl;

import com.flx.dis.read.write.split.dao.BookDao;
import com.flx.dis.read.write.split.entity.Book;
import com.flx.dis.read.write.split.service.BookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: Fenglixiong
 * @Date: 2021/6/9 17:57
 * @Description:
 */
@Slf4j
@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDao bookDao;

    @Override
    @Transactional
    public Long add(Book book) {
        bookDao.insert(book);
        log.info("add success id = "+book.getId());
        return book.getId();
    }

    @Override
    public Book get(Long id) {
        return bookDao.selectById(id);
    }
}
